package com.sec.android.app.myfiles.module.shortcut;

import android.app.FragmentManager;
import android.content.Context;
import android.net.Uri;

import com.sec.android.app.myfiles.info.AppFeatures;
import com.sec.android.app.myfiles.module.abstraction.AbsFileOperationImp;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.module.abstraction.FileRecord.StorageType;
import com.sec.android.app.myfiles.module.local.foldertree.FolderTreeDbTableInfo;
import com.sec.android.app.myfiles.operation.FileOperationArgs;
import com.sec.android.app.myfiles.operation.FileOperationException;
import com.sec.android.app.myfiles.operation.FileOperator;
import com.sec.android.app.myfiles.operation.FileOperator.Operation;
import com.sec.android.app.myfiles.operation.ProgressListener;
import com.sec.android.app.myfiles.provider.DbTableInfo;

import java.util.ArrayList;

public class ShortcutOperationImp extends AbsFileOperationImp {

    public ShortcutOperationImp(Context context, ProgressListener listener) {
        super(context, listener);
    }

    @Override
    protected void makeScanLists(Operation op, ArrayList<String> pathList, ArrayList<String> fileList, FileOperationArgs args, int handledCount) {
    }

    @Override
    protected boolean isSupport(FileRecord record) {
        boolean bRet = false;

        if (record.getStorageType() == StorageType.Shortcut) {
            bRet = true;
        }

        return bRet;
    }

    @Override
    protected boolean isSupportCopyMove(FileRecord src, FileRecord dst) {
        return false;
    }

    @Override
    protected boolean _copy(FileRecord src, FileRecord dst) {
        return false;
    }

    @Override
    protected boolean _move(FileRecord src, FileRecord dst) {
        return false;
    }

    @Override
    protected boolean _rename(FileRecord src, FileRecord dst) {
        return false;
    }

    @Override
    protected boolean _delete(FileRecord record) {
        boolean bRet = false;

        mProgresslistener.onProgressChanged(null, 0, 100);
        boolean needRefresh = false;
        if (ShortcutUtils.isExistFromShortcut(mContext, record)) {
            if (ShortcutUtils.deleteShortcutFromMyFiles(mContext, record)) {
                bRet = true;
                needRefresh = true;
                mProgresslistener.onProgressChanged(null, 100, 100);
            }
        }

        if (AppFeatures.isTabletUIMode() && needRefresh) {
            DbTableInfo tableInfo = FolderTreeDbTableInfo.getInstance();
            mContext.getContentResolver().notifyChange(Uri.parse(tableInfo.getUri()), null);
        }
        return bRet;
    }

    @Override
    protected FileRecord _mkdir(FileRecord dst, String name) {
        return null;
    }

    @Override
    protected ArrayList<FileRecord> _getListInDirectory(FileRecord record) {
        return null;
    }

    @Override
    protected void _preOperation(Operation operationType) {
    }

    @Override
    protected void _postOperation(Operation operationType, FileOperationArgs args, int handledCount) {
    }

    @Override
    protected FileRecord _getUniqueFileRecord(FileRecord record) {
        return null;
    }

    @Override
    protected boolean _copy(ArrayList<FileRecord> src, FileRecord dst, FragmentManager fragmentManager, boolean singleFile, boolean dupCheck,
                            FileOperator operator) throws FileOperationException {
        return false;
    }

    @Override
    protected boolean _move(ArrayList<FileRecord> src, FileRecord dst, FragmentManager fragmentManager, boolean singleFile, FileOperator operator, ArrayList<FileRecord> handledSrcList)
            throws FileOperationException {
        return false;
    }

    @Override
    protected boolean isSupportRecursiveCopyMove() {
        return false;
    }

}
